<html>
<head>
    <title>欢迎使用SN-generator&nbsp;Web工具</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script src="/common/js/jquery-1.7.1.min.js"></script>
    <script src="/common/js/jquery.base64.js"></script>
</head>
<body>
<br>
<br>
<span style="font-size: 30px;">生成TddlConfig配置</span>
<br>
<br>
<hr>
请输入配置信息:<br>
请输入项目名称(仅支持英文):<br><input id="projectName" style="width:800px" value="SN"><br>
<br>
请输入分组数量:<br><input id="groupNum" style="width:800px" value="4"><br>
<br>
请输入每个atom的读库数量(写库数量默认为1):<br><input id="readDbNum" style="width:800px" value="3"><br>
<br>
请输入默认数据库地址:<br><input id="defaultDbAddr" style="width:800px" value="192.168.0.x"><br>
<br>
请输入默认数据库端口:<br><input id="defaultDbPort" style="width:800px" value="3336"><br>
<br>
请输入默认最小链接数:<br><input id="minPoolSize" style="width:800px" value="5"><br>
<br>
请输入默认最大链接数:<br><input id="maxPoolSize" style="width:800px" value="10"><br>
<br>
请输入默认数据库名称:<br><input id="username" style="width:800px" value="10"><br>
<br>
请输入默认数据库密码:<br><input id="password" style="width:800px" value="10"><br>
<br>

<input id="CCC" type="button" onclick="createtddlConfig()" value="创建Tddl配置信息"/>
<br>
<textarea id="tddlConfig" style="width:800px;height:200px;">

</textarea>
<script>
    function createtddlConfig(){
        var projectName = $("#projectName").val();
        var groupNum = $("#groupNum").val();
        var readDbNum = $("#readDbNum").val();
        var defaultDbAddr = $("#defaultDbAddr").val();
        var defaultDbPort = $("#defaultDbPort").val();
        var minPoolSize = $("#minPoolSize").val();
        var maxPoolSize = $("#maxPoolSize").val();
        var username = $("#username").val();
        var password = $("#password").val();

        password = $.base64.encode(encodeURI(password));

        var buildurl ="/generatortddlconfig"
                +"?projectName="+projectName
                +"&groupNum="+groupNum
                +"&readDbNum="+readDbNum
                +"&defaultDbAddr="+defaultDbAddr
                +"&defaultDbPort="+defaultDbPort
                +"&minPoolSize="+minPoolSize
                +"&maxPoolSize="+maxPoolSize
                +"&username="+username
                +"&password="+password

        $.ajax({
            url: buildurl,
            type: "GET",
            dataType: "json",
            success: function (data) {
                if(data.resCode=="0000"){
                    $("#tddlConfig").val(data.resDesc);
                    alert("加载成功");
                }else{
                    alert("生成失败，错误原因如下:"+data.resDesc)
                }
            }
        });
    }
</script>
</body>
</html>